import request from '../../utils/request';
const notice = {
  state: {

  },

  getters: {

  },

  mutations: {

  },

  actions: {
    /**
     * 获取公告列表
     * @param payload{
     *  pageNum  string
     *  title    string
     *  startDay string
     *  endDay   string
     * }
    */
    GET_NOTICE_LIST({ commit }, payload) {
      console.log('GET_PERMISSION_LIST::');
      return new Promise((resolve, reject) => {
        request.get('/notice/list.htm', {
          params: payload
        }).then(res => {
          console.log('res::', res);
          console.log('commit::', commit);
          resolve(res);
        }).catch(err => {
          console.error('err::::', err);  
          reject(err);
        })
      });
    },

    /**
     * 公告管理-新建/更新/删除
     * @params payload {
     *  id string 公告id，为null新建
     *  title string 
     *  description string  描述
     *  content string
     *  state string deleted 删除
     * }
     * */ 
    HANDLE_NOTICE({ commit }, payload) {
      console.log('GET_PERMISSION_LIST::');
      return new Promise((resolve, reject) => {
        request.post('/notice/save.htm', payload).then(res => {
          console.log('res::', res);
          console.log('commit::', commit);
          resolve(res);
        }).catch(err => {
          console.error('err::::', err);  
          reject(err);
        })
      });
    },

    /**
     * 咨询管理-详情
     * @params payload{
     *  id string
     * }
     * */ 
    GET_NOTICE_DETAIL({ commit }, payload) {
      return new Promise((resolve, reject) => {
        request.post('/notice/detail.htm', payload).then(res => {
          console.log('commit::', commit);
          resolve(res);
        }).catch(err => {
          console.error('err::::', err);  
          reject(err);
        })
      });
    }

  }
}

export default notice